<?php
/**
 * The manifest of files that are local to specific environment.
 * This file returns a list of environments that the application
 * may be installed under. The returned data must be in the following
 * format:
 *
 * ```php
 * return [
 *     'environment name' => [
 *         'path' => 'directory storing the local files',
 *         'skipFiles'  => [
 *             // list of files that should only copied once and skipped if they already exist
 *         ],
 *         'setWritable' => [
 *             // list of directories that should be set writable
 *         ],
 *         'setExecutable' => [
 *             // list of files that should be set executable
 *         ],
 *         'setCookieValidationKey' => [
 *             // list of config files that need to be inserted with automatically generated cookie validation keys
 *         ],
 *         'createSymlink' => [
 *             // list of symlinks to be created. Keys are symlinks, and values are the targets.
 *         ],
 *     ],
 * ];
 * ```
 */

 /**
  * 自动搜索目录下全部的子目录
  */
function searchEnv(){
    $ret = [];
    $all = array_filter(scandir(__DIR__),function($val){
        return ($val != '.') && ($val != '..') && is_dir(__DIR__.'/'.$val);
    });

    if(!$all){
        return $ret;
    }

    foreach($all as $env){
        $r = __DIR__.'/'.$env.'/env.php';
        if(is_file($r)){
            $ret = array_merge($ret,require($r));
        }
    }
    return $ret;
}
searchEnv();

return searchEnv();
//
// return [
//     'Development' => [
//         'path' => 'dev',//路径
//         'setWritable' => [//可写
//             'backend/runtime',
//             'backend/web/assets',
//             'frontend/runtime',
//             'frontend/web/assets',
//         ],
//         'setExecutable' => [//可执行
//             'yii',
//             'yii_test',
//         ],
//         'setCookieValidationKey' => [//设置cookie的key
//             'backend/config/main-local.php',
//             'frontend/config/main-local.php',
//         ],
//     ],
//     'Production' => [
//         'path' => 'prod',
//         'setWritable' => [
//             'backend/runtime',
//             'backend/web/assets',
//             'frontend/runtime',
//             'frontend/web/assets',
//         ],
//         'setExecutable' => [
//             'yii',
//         ],
//         'setCookieValidationKey' => [
//             'backend/config/main-local.php',
//             'frontend/config/main-local.php',
//         ],
//     ],
// ];
